package org.idea.spring.ioc.container;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @link {BeanFactory} BeanFactory 作为ioc容器案例
 * @Author idea
 * @Date created in 9:47 下午 2020/5/3
 */
public class BeanFactoryAsIocContainer {

    public static void main(String[] args) {
        DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();
        //关于xml的配置文件地址
        String xmlPath = "META-INF/bean-dependency-injection";

        //专门用于读取xml配置bean属性的reader
        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(defaultListableBeanFactory);

        //返回一共加载了多少自定义的bean
        int beanCount = xmlBeanDefinitionReader.loadBeanDefinitions(xmlPath);
        System.out.println(beanCount);
    }
}
